package com.cheyun.netsalev3.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.cheyun.netsalev3.utils.MyIntent
import java.io.Serializable

/**
 * 默认基础ViewModel
 */
open class BaseViewModel : Serializable, ViewModel() {
    //用于Toast
    var toast = MutableLiveData<String>()
    //用于跳转
    var intent = MutableLiveData<MyIntent>()
    var finish = MutableLiveData<Boolean>()
    var finishWithBack = MutableLiveData<Int>()

    fun MyToast(text: String) {
        toast.postValue(text)
    }

    fun myStartActivity(intent: MyIntent) {
        this.intent.postValue(intent)
    }

    fun myFinish() {
        finish.postValue(true)
    }

    fun myFinish(result:Int){
        finishWithBack.postValue(result)
    }

}